import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
//服务器端：接收到的数据写入" D:\JavaLearn\idea\Code\JavaSE_Code\MyNet\src\tmp\data.txt "

public class TCP_Demo2_server_plus {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10001);
        Socket accept = serverSocket.accept();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(accept.getInputStream()));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("D:\\JavaLearn\\idea\\Code\\JavaSE_Code\\MyNet\\src\\tmp\\data.txt"));
        String line;
        while((line = bufferedReader.readLine()) != null){
            bufferedWriter.write(line);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }
        serverSocket.close();
        bufferedWriter.close();
    }
}
